//
// Created by chizuru on 2025/9/19.
//
#include "aop.hpp"
#include "proxy.hpp"
#include <iostream>
using namespace std;
struct Sub : public aop::AutoProxy<Sub>{
    int sub_impl(int a, int b) {
        return a - b;
    }

    aop::Advisable<int, int, int> sub_advisor;
    int sub(int a, int b) { return sub_advisor(a, b); }

    Sub() : sub_advisor(aop::AutoProxy<Sub>::bind_to_this(this, &Sub::sub_impl)){
        sub_advisor.add_before([](int &a, int &b){
            a = -a;
        });
        sub_advisor.add_around([](std::function<int(int&, int&)> proceed, int &a, int &b)->int {
            return proceed(a,b);
        });
        sub_advisor.add_after_value([](int &r, int &a, int &b){
            printf("end\n");
        });
    }
};